STK.register('app.mod.login', function($){
    /*
     * spec = {
     region :
     tag :
     over :
     delay :
     }
     */
    return function(){
    
        var info = '<div class="errorLayer" node-type="tipBox" style="position: absolute; left: 938px;top: 113px; z-index: 1010; display:none; "><div class="mid"><div class="close" onclick="this.parentNode.style.display=\'none\';">x</div><div class="conn"><p class="bigtxt" id="mod_login_title">登录名或密码错误</p><span class="stxt" id="mod_login_content" style="padding:0px;"><p class="stxt2">1、登录名是邮箱地址的用户</p><p class="stxt">请输入：yourname@sina.com</p><p class="stxt2"> 2、手机通行证方式注册的用户</p><p class="stxt">请输入：yourname@3g.sina.cn</p><p class="stxt2"> 3、请检查登录名大小写是否正确</p><p class="stxt2"> 4、请检查密码大小写是否正确</p></span></div></div></div>';
        
        var LOGINBOXTEMPLATE = '<div node-type="loginBox"  class="login-container"><div class="login-form"><fieldset>\
		<label class="login" for="email">Email:</label><input class="text" id="email" name="email" type="text">\
		<p class="username-hint">ex: joe@example.com</p>\
		<label class="login" for="password">Password:</label><input class="text" id="password" name="password" type="password">\
		<p class="remember_me"><input id="remember_me" name="remember_me" type="checkbox" value="1">\
		<label class="text" for="remember_me">Stay signed in</label></p>\
		<p><a node-type="loginBtn" class="submit green awesome">Log in</a></p>\
		<div class="forgot-password"><a href="#" node-type="forgotBtn">Forgot your password?</a></div>\
		</fieldset></div>' + info + '</div>';
        
        var dom = $.builder(LOGINBOXTEMPLATE), lbox = dom.list['loginBox'][0], lbtn = dom.list['loginBtn'][0], fbtn = dom.list['forgotBtn'][0], tbox = dom.list['tipBox'][0], vr_email = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/, vr_password = /[A-Za-z0-9]{1,20}$/;
        
        $.E('mainbox').appendChild(lbox);
        
        var loginEvent = function(){
            var json = $.htmlToJson(lbox, ["INPUT"], false);
            if (vr_email.test(json.email) && vr_password.test(json.password)) {
                json['func'] = 'login';
                $.app.common.request({
                    url: 'user.s',
                    args: json,
                    cb: function(){
                        tbox.style.display = "none";
                    }
                });
            }
            else {
                tbox.style.display = "";
            }
        };
        $.addEvent(lbtn, 'click', loginEvent);
        //			$.addEvent(fbtn, 'click', function(){});
        
        $.gListener.register('login', function(){
            lbox.style.display = "none";
        });
        $.gListener.register('logout', function(){
            lbox.style.display = "";
        });
    };
});